﻿using System;
using System.Collections.Generic;

namespace SortOf
{
    public static class InsertionSort
    {
        public static void Sort<T>(IList<T> list) where T : IComparable<T>
        {
            for (int i = 1; i < list.Count; i++)
            {
                T value = list[i];
                int j = i - 1;

                while ((j >= 0) && (list[j].CompareTo(value) > 0))
                {
                    list[j + 1] = list[j];
                    j--;
                }

                list[j + 1] = value;
            }
        }
    }
}
